import java.util.StringTokenizer;

class P441_39643 {

	public static void main(String[] args) {
		String line = readLn();

		boolean first = true;
		
		while (!"0".equals(line)) {
			if (!first) System.out.println();
			process(line);
			line = readLn();
			first = false;
		}
	}

	private static void process(String line) {
		StringTokenizer st = new StringTokenizer(line);
		int x = Integer.parseInt(st.nextToken());

		int[] S = new int[x];

		for (int i = 0; i < x; i++) {
			S[i] = Integer.parseInt(st.nextToken());

		}

		for (int j = 0; j < x - 5; j++)
			for (int k = j + 1; k < x - 4; k++)
				for (int l = k + 1; l < x - 3; l++)
					for (int m = l + 1; m < x - 2; m++)
						for (int n = m + 1; n < x - 1; n++)
							for (int o = n + 1; o < x; o++) {
								System.out.println(S[j] + " " + S[k] + " " + S[l] + " " + S[m] + " " + S[n] + " " + S[o]);
							}

	}

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}